package com.om.base;

import java.util.HashMap;

public class DataRow extends HashMap<String, Object> {
	public String[] Titles = new String[0];
	public String tableName = "";
	
	public void set(String name, Object value) {
		try {
			if (value == null)
				return;
			this.put(name, value);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	

	
	public Object get(int i) {
		try {
			String field = this.getField(i);
			
			return this.get(field);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}

	public Object get(String name) {
		try {
			return super.get(name);
		} catch (Exception e) {
			System.out.println(e.getMessage() + "\r\n" + e.getStackTrace());
		}
		return null;
	}

	public String getStringValue(String name) {
		String strValue = "";
		Object value = get(name);
		if ((value != null) && (!("null".equals(value)))) {
			strValue = value + "";
		}
		return strValue;
	}

	public void setEmpty(String field) {
		this.put(field, "");
	}

	public void clear() {
		this.clear();
	}

	public String getFieldName(int i) {
		try {
			return this.Titles[i];
		} catch (Exception e) {
			System.out.println(e.getMessage() + "\r\n" + e.getStackTrace());
		}
		return "";
	}
	public String getField(int i) {
		String field="";
		try {
			field = (String)this.keySet().toArray()[i];
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return field;
	}

	
}
